import java.util.LinkedList;
import java.util.Scanner;

/**
 * @Author wonghiu
 * @Date 2021/8/8 20:25
 * @Version 1.0.1
 */
public class pdd33 {
    // L,R,D,(,)
    public static void main(String[] args) {
//        String input = "()DD";
//        char[] input = new char[]{'(',')',''};
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String input = sc.next();
        LinkedList<Character> stackLeft = new LinkedList<>();
        LinkedList<Character> stackRight = new LinkedList<>();
        int leftCount = 0;
        int rightCount = 0;

        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i)=='(') {
                stackLeft.addLast(input.charAt(i));
                leftCount++;
            }else if (input.charAt(i)==')' ){
                stackLeft.addLast(input.charAt(i));
                rightCount++;
            }else if (input.charAt(i)=='L' && !stackLeft.isEmpty()){
                stackRight.addLast(stackLeft.pollLast());
            }else if (input.charAt(i)=='R' && !stackRight.isEmpty()){
                stackLeft.addLast(stackRight.pollLast());
            }else if (input.charAt(i)=='D' && !stackLeft.isEmpty()){
                Character character = stackLeft.removeLast();
                if (character=='('){
                    leftCount--;
                }else {
                    rightCount--;
                }

            }
//            System.out.println(i);
            if (rightCount==leftCount && rightCount!=0){
                int dep = 0;
                int maxDep = 0;
//                LinkedList<Character> stackTemp = new LinkedList<>();

                for(char curStr:stackLeft){
//                    System.out.print(curStr);
                    if (curStr=='('){
                        dep++;
                        if (dep>maxDep){
                            maxDep = dep;
                        }
                    }else {
                        dep--;
                    }
                }

                for(char curStr:stackRight){
//                    System.out.print(curStr);
                    if (curStr=='('){
                        dep++;
                        if (dep>maxDep){
                            maxDep = dep;
                        }
                    }else {
                        dep--;
                    }
                }
                System.out.print(maxDep+" ");
            }else {
                System.out.print(-Math.abs(leftCount-rightCount)+" ");
            }
        }
    }
}
